import { Dark } from "quasar";
import { useSettingsStore } from "src/stores/storeSettings";
import type { NamedColor } from "quasar";
// 格式化金额
export function useAmountFormat(amount: number | null): string {
  const settingsStore = useSettingsStore();
  const value = amount ?? 0; // 确保amount是数字
  // 判断金额的正负
  let pre = "";
  if (value > 0) {
    pre = "+";
  } else {
    pre = "-";
  }

  // 金额符号
  const aountSymbol: string = settingsStore.settings.currencySymbol;
  const absAmount = Math.abs(value);
  return pre + aountSymbol + new Intl.NumberFormat("zh-CN").format(absAmount);
}

export function useAmountColor(amount: number | null): string {
  const value = amount ?? 0; // 确保amount是数字
  if (value > 0) {
    return "text-positive";
  } else return "text-negative";
}

/**
 * 不同主题返回不用样式
 */

export function useLightOrDark(
  lightString: NamedColor,
  darkString: NamedColor,
): NamedColor {
  return (!Dark.isActive ? lightString : darkString) as NamedColor;
}
